package com.xcf.cloud.codeapi.client;

import com.xcf.cloud.codeapi.CodeConstant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author xiaocf
 */
@FeignClient(name = CodeConstant.SERVICE_NAME, path = CodeConstant.SERVICE_CONTEXT_PATH)
       // url = CodeConstant.SERVICE_ENDPOINT)
public interface CodeClient {

    /**
     * ⽣成验证码并发送到对应邮箱，
     *
     * @param email 邮箱地址
     * @return 成功true, 失败 false
     */
    @GetMapping(CodeConstant.Path.GET_CODE_BY_EMAIL)
    boolean getCode(@PathVariable("email") String email);

    /**
     * 校验验证码是否正确，0正确1错误2超时
     *
     * @param email 邮箱地址
     * @param code  验证码
     * @return 0正确 1错误 2超时
     */
    @GetMapping(CodeConstant.Path.VALID_CODE_BY_EMAIL)
    Integer validCode(@PathVariable("email") String email, @PathVariable("code") String code);
}
